using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using sdm.exam.domain;
using sdm.exam.domain.Abstract;
using sdm.exam.domain.DataContext;
using sdm.exam.domain.Entities;

namespace sdm.exam.test.Manager
{
    [TestClass]
    public class ExamManagerTest
    {
        /// <summary>
        /// Test whether or not we are getting exams by a spefic education.
        /// </summary>
        [TestMethod]
        public void GetListByEducationTest()
        {
            Ninjector.Kernel.Bind<ISdmExamRepository>().ToConstant(new DataContext(ConnectionStrings.TestConnection));

            var manager = new sdm.exam.domain.Manager.ExamManager();

            var education = new Education() { Id = 1, Name = "Test education" };
            var education1 = new Education() { Id = 2, Name = "Test education1" };

            var exam = new Exam { Education = education };
            var exam1 = new Exam { Education = education1 };

            manager.AddExam(exam);
            manager.AddExam(exam1);

            List<Exam> list = manager.GetExamsListByEducation(education);

            foreach (Exam exams in list)
                Assert.AreEqual(education.Name, exams.Education.Name);
        }

        [TestMethod]
        public void AddExamTest()
        {
            Ninjector.Kernel.Bind<ISdmExamRepository>().ToConstant(new DataContext(ConnectionStrings.TestConnection));

            var manager = new sdm.exam.domain.Manager.ExamManager();

            var exam = new Exam();

            int first = manager.GetListOfExams().Count;

            manager.AddExam(exam);

            int second = manager.GetListOfExams().Count;

            Assert.AreEqual(second, first + 1);
        }
    }
}
